package game.map 
{
	import flash.display.MovieClip;
	/**
	 * ...
	 * @author rnk
	 */
	public class Map 
	{
		public var map_bg:MovieClip;
		public var map_info:MovieClip;
		public var provinces:Array=[];
		
		
		public function Map() 
		{
			
		}
		
		public function Init(mapInfo:Object):void
		{
			map_bg = mapInfo.map_bg;
			map_info = mapInfo.map_info;
			
			var provincesInfo:Array = mapInfo.provinces;
			for (var i:int = 0; i < provincesInfo.length; i++)
			{
				var provInfo:Object = provincesInfo[i];
				
				var prov:Province = new Province();
				prov.uid = provInfo.uid;
				prov.name = provInfo.name;
				prov.routes = provInfo.routes;
				prov.type = provInfo.type;
				provinces.push(prov);
			}
			
			
		}
		
		public function GetRouteMap():Array
		{
			var routeMap:Array = [];
			for (var i:int = 0; i < provinces.length; i++)
			{
				var provinceA:Province = provinces[i];
				var row:Array = [];
				for (var j:int = 0; j < provinces.length; j++)
				{
					var provinceB:Province = provinces[j];
					
					if (i == j)
						row.push(false);
					else
						row.push(provinceA.HasRoute(provinceB) );
				}
				routeMap.push(row);
			}
			return routeMap;
		}
		
		public function GetProvince(uid:String):Province
		{
			for (var i:int = 0; i < provinces.length; i++)
			{
				var province:Province = provinces[i];
				if (province.uid == uid)
					return province;
			}
			return null;
		}
		
		
	}

}